//
//  CustomTableViewCell.swift
//  ios14cellConfiguration
//
//  Created by 李煜 on 2023/3/16.
//

import UIKit

struct ViewModel {
  var icon: UIImage?
  var title: String?
}

class CustomTableViewCell: UITableViewCell {
  // cellid设置
  //  static let cellID = NSStringFromClass(CustomTableViewCell.self) as String
  static let cellID = "CustomTableViewCell"

  // MARK: - 模型属性

  var item: ViewModel = .init()

  //  iOS14更新配置
  override func updateConfiguration(using state: UICellConfigurationState) {
    var newConfiguration = defaultContentConfiguration().updated(for: state)

    if state.isHighlighted || state.isSelected {
      newConfiguration.image = item.icon
      newConfiguration.text = item.title
    }
    contentConfiguration = newConfiguration
  }
}
